"use client";

import React from "react";
import { useCookies } from "next-client-cookies";
import { useRouter } from "next/navigation";

export default function LogoutForm() {
  const cookies = useCookies();
  const rotuer = useRouter();

  const logout = async () => {
    if (window.confirm("确定退出？")) {
      cookies.remove("username");
      rotuer.push("/login");
    }
  };
  return (
    <div>
      <button onClick={logout} className="border px-3 py-1">
        退出登录
      </button>
    </div>
  );
}
